//
//  SDuanzi2TableViewCell.m
//  News
//
//  Created by dlios on 15-5-14.
//  Copyright (c) 2015年 PEAK. All rights reserved.
//

#import "SDuanzi2TableViewCell.h"

@interface SDuanzi2TableViewCell ()

@end

@implementation SDuanzi2TableViewCell
- (void)dealloc
{
    [_lable release];
    [_button1 release];
    [_button2 release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.lable = [[UILabel alloc] init];
        _lable.numberOfLines = 0;

        _lable.lineBreakMode = NSLineBreakByWordWrapping;
        _lable.font = [UIFont systemFontOfSize:17];
        
        _lable.frame = CGRectMake(10, 0, [UIScreen mainScreen].bounds.size.width  - 20, [UIScreen mainScreen].bounds.size.height / 1.1);
           [self.contentView addSubview:_lable];
        [_lable release];
        

    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat f = [[self class]heightWithText:_lable.text];
//    NSLog(@"=====%@",_lable.text);
    CGRect frame =  self.lable.frame;
    frame.size.height = f + 50;
    self.lable.frame = frame;
    

}
-(void)setSHappy:(SHppyObject *)sHappy
{
    if (_sHappy != sHappy) {
        [_sHappy release];
        _sHappy = [sHappy retain];
    }
    _lable.text = sHappy.digest;
    
}
+(CGFloat)heightWithText:(NSString *)text
{
    
    NSDictionary *dic = @{NSFontAttributeName :[UIFont systemFontOfSize:17]};
        CGSize size = CGSizeMake(350, 1000);
    CGRect rect = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
